# main.py
from fastapi import FastAPI
from educate_ai.database import engine, Base
from educate_ai.online_answer_records.router import router as online_answer_records_router
from educate_ai.papers.paper_controller import router as papers_router
from educate_ai.questions_part.router import app as questions_router
from educate_ai.answer_records.router import router as answer_records_router
from educate_ai.user.controller import router as user_router
import uvicorn

# 导入所有模型以确保表创建
from educate_ai.online_answer_records import models as online_answer_records_models
from educate_ai.papers import paper_model
from educate_ai.questions_part import model
from educate_ai.answer_records import models as answer_records_models
from educate_ai.user import models as user_models

# 创建所有表
Base.metadata.create_all(bind=engine)

app = FastAPI(title="教育AI系统", version="0.0.1")

# 包含路由
app.include_router(online_answer_records_router)
app.include_router(papers_router)
app.include_router(questions_router)
app.include_router(answer_records_router)
app.include_router(user_router)

@app.get("/")
def read_root():
    return {"message": "欢迎使用教育AI系统API"}

if __name__ == "__main__":
    uvicorn.run('main:app', host='localhost', port=8000, reload=True)
